package com.ruoyi.web.controller.arborrow;

import java.util.List;

import com.ruoyi.web.domain.ArBorrowInfo;
import com.ruoyi.web.service.IArBorrowInfoService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.activiti.api.process.model.ProcessInstance;
import org.activiti.api.process.model.builders.ProcessPayloadBuilder;
import org.activiti.api.process.model.payloads.StartProcessPayload;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 借阅管理Controller
 *
 * @author ruoyi_ln
 * @date 2022-02-15
 */
@RestController
@RequestMapping("/borrowRegister/info")
public class ArBorrowInfoController extends BaseController
{
    @Autowired
    private IArBorrowInfoService arBorrowInfoService;

    /**
     * 查询借阅管理列表
     */
    @PreAuthorize("@ss.hasPermi('borrowRegister:info:list')")
    @ApiOperation("查询分类管理列表")
    @GetMapping("/list")
    public TableDataInfo list(ArBorrowInfo arBorrowInfo)
    {
        startPage();
        List<ArBorrowInfo> list = arBorrowInfoService.selectArBorrowInfoList(arBorrowInfo);
        return getDataTable(list);
    }

    /**
     * 导出借阅管理列表
     */
    @PreAuthorize("@ss.hasPermi('borrowRegister:info:export')")
    @Log(title = "借阅管理", businessType = BusinessType.EXPORT)
    @ApiOperation("获取借阅管理详细信息")
    @ApiImplicitParam(name = "recNo", value = "借阅管理编号", required = true, dataType = "String", paramType = "传借阅管理编号")
    @GetMapping("/export")
    public AjaxResult export(ArBorrowInfo arBorrowInfo)
    {
        List<ArBorrowInfo> list = arBorrowInfoService.selectArBorrowInfoList(arBorrowInfo);
        ExcelUtil<ArBorrowInfo> util = new ExcelUtil<ArBorrowInfo>(ArBorrowInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取借阅管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('borrowRegister:info:query')")
    @GetMapping(value = "/selectbyid/{recNo}")
    public AjaxResult getInfo(@PathVariable("recNo") String recNo)
    {
        return AjaxResult.success(arBorrowInfoService.selectArBorrowInfoById(recNo));
    }

    /**
     * 新增借阅管理
     */
    @PreAuthorize("@ss.hasPermi('borrowRegister:info:add')")
    @Log(title = "借阅管理", businessType = BusinessType.INSERT)
    @ApiOperation("新增借阅管理")
    @ApiImplicitParam(name = "arBorrowInfo", value = "借阅管理对象", required = true, dataType = "ArBorrowInfo", paramType = "传借阅管理对象")
    @PostMapping
    public AjaxResult add(@RequestBody ArBorrowInfo arBorrowInfo)
    {
        return arBorrowInfoService.insertArBorrowInfo(arBorrowInfo);
    }

    /**
     * 修改借阅管理
     */
    @PreAuthorize("@ss.hasPermi('borrowRegister:info:edit')")
    @Log(title = "借阅管理", businessType = BusinessType.UPDATE)
    @ApiOperation("修改借阅管理")
    @ApiImplicitParam(name = "arBorrowInfo", value = "借阅管理对象", required = true, dataType = "ArBorrowInfo", paramType = "传借阅管理对象")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ArBorrowInfo arBorrowInfo)
    {
        return toAjax(arBorrowInfoService.updateArBorrowInfo(arBorrowInfo));
    }

    /**
     * 删除借阅管理
     */
    @PreAuthorize("@ss.hasPermi('borrowRegister:info:remove')")
    @Log(title = "借阅管理", businessType = BusinessType.DELETE)
    @ApiOperation("删除借阅管理")
    @ApiImplicitParam(name = "recNos", value = "借阅管理编号数组", required = true, dataType = "String[]", paramType = "传借阅管理编号数组")
    @GetMapping("/{recNos}")
    public AjaxResult remove(@PathVariable String[] recNos)
    {
        return toAjax(arBorrowInfoService.deleteArBorrowInfoByIds(recNos));
    }
}
